

        <form class="layui-form" action="">
            <input name="ConfigConstant[id]" type="hidden" value="<?=$model->id?>" />
            <input name="_csrfBackend" type="hidden" value="<?=\Yii::$app->request->csrfToken?>" />
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>变量中文名</label>
                <div class="layui-input-inline">
                     <input type="text" name="name" lay-verify="required" value="<?=$model->name ?>" autocomplete="off" class="layui-input" placeholder="变量名" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>变量英文名</label>
                <div class="layui-input-inline">
                     <input type="text" name="name_en" lay-verify="required" value="<?=$model->name_en ?>"  autocomplete="off" placeholder="请输入变量英文名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>变量值</label>
                <div class="layui-input-inline">
                     <input type="text" name="value" lay-verify="required" value="<?=$model->value ?>"  autocomplete="off" placeholder="请输入变量的值" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>操作说明</label>
                <div class="layui-input-inline">
                     <input type="text" name="description" lay-verify="required" value="<?=$model->description ?>"  autocomplete="off" placeholder="请输入操作说明" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span class="x-red"></span>变量类型</label>
                    <div class="layui-input-inline"> 
                        <select name="type" id="type" lay-search="" lay-verify="required" >
                            <option value="0" <?=$model->type===0?"selected":""?> >全局变量</option>
                            <option value="1" <?=$model->type===1?"selected":""?> >前台</option>
                            <option value="2" <?=$model->type===2?"selected":""?> >后台</option>
                            <option value="3" <?=$model->type===3?"selected":""?> >API</option>
                        </select>
                    </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    提交
                </button>
            </div>

            
            </div>
        </form>

<script type="text/javascript">
    /*--------表单部分-------*/
    layui.use(['form'], function(){
        var form = layui.form
        ,layer = layui.layer
        // 提交表单
        form.on('submit(add)', function(data){
            var index = layer.load('添加中',1, {shade: false, offset: '300px'});
            $.post("<?=\yii\helpers\Url::toRoute('config-variable/create') ?>",data.field,function(res){
                if(res.code==200){
                        layer.msg('添加成功', {
                                time: 2000,//3s后自动关闭
                            },function(){
                                layer.close(index);
                                window.parent.location.reload(); //刷新父页面
                            });
                }else{
                    layer.msg('添加失败'+res.message, {
                                time: 2000,//3s后自动关闭
                            },function(){
                                layer.close(index);
                                window.parent.location.reload(); //刷新父页面
                            });
                }
            });

            return false;
        });//监听提交
    })

</script>